package BOOK_describe;

import java.util.Scanner;

//管理员和非管理员
public class USER_main {
    public static user_one login() {
        System.out.print("亲输入你的名字: ");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.nextLine();
        System.out.println("欢迎" + name + "进入图书系统");
        System.out.println("亲输入你的身份" +
                "\n1,普通用户  2，管理员");
        int answer = scanner.nextInt();
        if (answer == 1) {
            return new Common_user(name);
        } else {
            return new Manager_user(name);
        }
    }

    //初始话书架，放几本苏
    public static void Init_bookshelves(Bookshelves bookshelves) {
        BOOK book1 = new BOOK("by_hadage", "hadage", "5.20");
        bookshelves.setBookshelves(book1);//chuzun book1
    }

    //系统菜单
    public static void Run(user_one name) {
        Bookshelves bookshelves = new Bookshelves();
        Init_bookshelves(bookshelves);//在书架中默认储存几本书
        //选择功能
        while (true) {
            name.menu();
            System.out.println("功能选择");
            Scanner scanner = new Scanner(System.in);
            int choice = scanner.nextInt();
            name.use_option(bookshelves, choice);
        }
    }
    public static void main(String[] args) {
        System.out.println("hh");
        user_one name = login();
        Run(name);
    }
}

